package cn.wolfcode.mapper;

import cn.wolfcode.elasticjob.domain.FileCustom;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 *  连接MySQL数据库的mapper接口
 */
@Mapper
public interface FileCustomMapper {
    //执行SQL的方式有两种：mapper.xml 和注解的方式，这里使用注解的方式执行SQL语句

    @Select("SELECT * FROM t_file_custom WHERE backedUp = 0")
    List<FileCustom> selectAll();

    @Select("select * from t_file_custom where backedUp = 0 and type=#{fileType}")
    List<FileCustom> selecByType(String fileType);

    @Update("UPDATE t_file_custom SET backedUp = #{state} WHERE id = #{id}")
    int changeState(@Param("id") Long id,@Param("state") int state);

    @Select("SELECT * FROM t_file_custom WHERE backedUp = 0 limit 0,#{size}")
    List<FileCustom> fetchData(int size);

}
